package com.xunqi.ad.controller;

import com.alibaba.fastjson.JSON;
import com.xunqi.ad.exception.AdException;
import com.xunqi.ad.form.CreateUserForm;
import com.xunqi.ad.service.IUserService;
import com.xunqi.ad.vo.CreateUserResponseVo;
import com.xunqi.ad.vo.ResponseVo;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;
import javax.validation.Valid;

/**
 * @Description:
 * @Created with IntelliJ IDEA.
 * @author: 夏沫止水
 * @createTime: 2020-04-30 21:43
 **/
@Slf4j
@RestController
public class UserOPController {

    @Resource
    private IUserService userService;

    @PostMapping(value = "/create/user")
    public ResponseVo<CreateUserResponseVo> createUser(@Valid @RequestBody CreateUserForm form) throws AdException {

        log.info("ad-sponsor:createUser -> {}", JSON.toJSONString(form));

        ResponseVo<CreateUserResponseVo> userResponseVo = userService.createUser(form);

        return userResponseVo;
    }


    @GetMapping(value = "/test")
    public String test() {
        return "test";
    }

}
